package com.fhz.library_log.logger

import android.content.Context
import android.util.Log
import com.fhz.library_log.ILogger
import com.fhz.library_log.LoggerLevel

/**
 * 时间:2023/10/17
 * @author Mr.Feng
 * 简述: TODO
 */
class LogcatLogger : ILogger {

    private var isDebug = true //是否Debug
    private var TAG = "mvi" //默认TAG
    private var level = LoggerLevel.DEBUG // 默认日志等级
    private var loggerFormat = "(%s --->%s）" //格式化


    override fun d(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.DEBUG.ordinal){
            Log.d(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun v(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.VREBOSE.ordinal){
            Log.v(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.INFO.ordinal){
            Log.i(TAG, String.format(loggerFormat,tag,log))
        }

    }

    override fun w(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.WARN.ordinal){
            Log.w(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun e(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.ERROR.ordinal){
            Log.e(TAG, String.format(loggerFormat,tag,log))
        }
    }

    override fun setDebug(isDeug: Boolean) {
       this.isDebug = isDebug
    }

    override fun setLogTAG(tag: String) {
        this.TAG = tag
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setSaveUrl(url: String) {

    }

    override fun setContext(context: Context?) {

    }
}